package com.hs.runner;

import org.elasticsearch.client.RestHighLevelClient;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * @Author: 何森
 * @Since: 2023-07-28-9:55
 */

// 测试项目启动时预处理
@Component
public class TestRunner implements CommandLineRunner {

    @Resource
    private RestHighLevelClient restHighLevelClient;

    @Override
    public void run(String... args) throws Exception {
        System.out.println("程序初始化...");
//        // 测试一下es
//        GetRequest request = new GetRequest("demo","3");
//        GetResponse response = restHighLevelClient.get(request, RequestOptions.DEFAULT);
//        System.out.println(response.getSourceAsString());// 打印文档内容
//        restHighLevelClient.close();
    }
}
